package com.zh.juc.lock;

/**
 * @Author: zhanghuan
 * @date: 2022/10/9 19:16
 * @description: create it
 * <p>
 * 面试题：为什么任何一个对象都可以成为一个锁？
 * <p>
 * javap -c .\LockSyncDemo.class
 * javap -v .\LockSyncDemo.class
 */
public class LockSyncDemo {


    Object object = new Object();

    public void m1() {

        synchronized (object) {
            System.out.println("-----1");
            throw new RuntimeException("---e");
        }
    }

    public synchronized void m2() {
        System.out.println("--------------2");
    }

    public static synchronized void m3() {
        System.out.println("-------------3");
    }

    public static void main(String[] args) {

    }

}
